function SignRule_Data(data) {
	var buffer = new StringBuffer();
	$(data).each(function(i,info){
		buffer.append('<div class="signrulelist border-bottom" id="'+info.ID+'"><div class="signrulename"><div class="realname">'+info.Name+'</div></div><div class="signruleinfo"><font class="blacks">允许误差：</font>'+info.Error+'米</div><div class="signruleinfo"><font class="blacks">相关员工：</font>'+info.ToUsersName+'</div><div class="signruleinfo"><font class="blacks">考勤地点：</font>'+info.Address+'</div><div class="signruleinfo"><font class="blacks">工作日期：</font>'+info.WorkDay+'</div><div class="signruleinfo"><font class="blacks">上班时间：</font>'+(info.UpTime1+'-'+info.DownTime1 + ' &nbsp; &nbsp; '+info.UpTime2+'-'+info.DownTime2)+'</div></div>');
	});
	return buffer.toString();
};

function Receive_SignRule(pageindex)
{
	var data = {};
			data.act = "Find_SignRule_Pager";
			data.userid=userid;
			data.comid=comid;
			data.source=source;
			data.pageindex=pageindex;
			data.pagesize=1000;
			data.sign=GetSign(data.act);
			mui.getJSON(admin_domain, data, function(json) {
				
				if(json.data.signrule.length>0)
				{
					$("#contentlist1").html('<div id="nlist" style="float:left; min-height: '+sheight+'px;"></div>');
					$("#contentlist1").append(SignRule_Data(json.data.signrule));
					setTimeout(function(){
						Init_SignRule();
					},500); //需要延迟500毫秒加载，否则当数量少时不能下拉
					$("#contentlist1").append('<div class="loading">长按可以删除哦</div>');
					
				}else
				{
					if(pageindex==1)
					{
						//$("#contentlist1").html("");
						$("#loading1").html("点击有上角加号添加新规则");
					}
					else
					{
						$("#loading1").html("没有更多了");
					}
				}
				
         		pageindex = parseInt($("#divmsg1").attr("pageindex"))+1;
         		$("#divmsg1").attr("pageindex",pageindex);
			});
};

function SignRule_Search(){
	Receive_SignRule(1);
};

function Init_SignRule()
{
	mui("#contentlist1").off("tap",".signrulelist");
	mui("#contentlist1").off("longtap",".signrulelist");
	mui("#contentlist1").on("tap",".signrulelist",function(){
		obj=$(this);
		OpenWindow(2,"修改打卡规则","保存",function(){
			Save_SignRule();
		});
		$("#contentlist2").html(SignRuleAdd_Code($(this).attr("id")));
		Init_SignRuleAdd();
	});
	mui("#contentlist1").on("longtap",".signrulelist",function(){
		obj=$(this);
        	plus.nativeUI.confirm("确定要删除吗？", function(event){
				if(event.index==1)
				{
					var data = {};
				    data.act = "Delete_SignRule";
				    data.ids = obj.attr("id");
				    data.userid=userid;
					data.comid=comid;
					data.source=source;
					data.sign=GetSign(data.act);
				    mui.getJSON(admin_domain, data, function(json) {
				    	plus.nativeUI.toast(json.msg);
						if(json.state)
						{
							obj.hide(300);
					        if($("#iframe .title .name").html()=="消息"){ //如果是通过消息页面进行设置的，执行下面代码
					            Init_Notice();
					        }
						}
				    });	
				}
			},"提示", ["取消","确认"]); 
		
		
	});
};
